package com.example.vue.sys.action;

import com.example.vue.comm.domain.ResultData;
import com.example.vue.sys.service.SysMenuService;
import com.example.vue.sys.vo.MenuFormVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * 系统菜单管理
 *
 * @author zhouxl
 * @DATE 2020/11/30
 * @descriptoin
 */
@Api("菜单管理")
@Controller
@RequestMapping("/api/sysMenu")
public class SysMenuAction {

    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 菜单的树结构信息
     *
     * @return
     */
    @ApiOperation("菜单查询 - 树结构")
    @ApiParam(name = "菜单编号", value = "")
    @RequestMapping(value = "/menuTree", method = RequestMethod.GET)
    @ResponseBody
    public Object menuTree(@RequestParam Map<String, Object> params) {
        ResultData data = sysMenuService.menuTree(params);
        return data;
    }

    /**
     * 添加菜单
     *
     * @return
     */
    @RequestMapping(value = "/addMenu", method = RequestMethod.POST)
    @ResponseBody
    public Object addMenu(MenuFormVo menuForm) {
        ResultData data = sysMenuService.addMenu(menuForm);
        return data;
    }

    /**
     * 查询菜单列表信息
     *
     * @return
     */
    @RequestMapping(value = "/menuList", method = RequestMethod.POST)
    @ResponseBody
    public Object menuList(MenuFormVo menuForm) {
        ResultData data = sysMenuService.menuList(menuForm);
        return data;
    }

    /**
     * 查询菜单信息
     *
     * @return
     */
    @RequestMapping(value = "queryMenuById", method = RequestMethod.POST)
    @ResponseBody
    public Object queryMenuById(@RequestParam Map<String, Object> params) {
        ResultData data = sysMenuService.queryMenuById(params);
        return data;
    }


    /**
     * 编辑保存菜单信息
     *
     * @return
     */
    @RequestMapping("editMenu")
    @ResponseBody
    public Object editMenu(MenuFormVo vo) {
        ResultData data = sysMenuService.editMenu(vo);
        return data;
    }

    /**
     * 删除菜单
     *
     * @return
     */
    @RequestMapping(value = "deleteMenu", method = RequestMethod.POST)
    @ResponseBody
    public Object deleteMenu(@RequestParam Map<String, Object> params) {
        return sysMenuService.deleteMenu(params);
    }

    /**
     * 删除当前菜单及其下面所有的子菜单信息
     *
     * @param params
     * @return
     */
    @RequestMapping(value = "deleteMenuList", method = RequestMethod.POST)
    @ResponseBody
    public Object deleteMenuList(@RequestParam Map<String, Object> params) {
        return sysMenuService.deleteMenuList(params);
    }

}
